{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="order_no" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-block">
                        <input type="text" name="realname" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobile" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                {if $role['role_id']<3}
                <div class="layui-inline">
                    <label class="layui-form-label">司机</label>
                    <div class="layui-input-block">
                        <select name="driver">
                            <option value="">不限</option>
                            {foreach $driver as $key=>$val}
                            <option value="{$val.id}">{$val['name']}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                {/if}
                <div class="layui-inline">
                    <label class="layui-form-label">订单状态</label>
                    <div class="layui-input-block">
                        <select name="status">
                            <option value="">不限</option>
                            {foreach $o_status as $key=>$val}
                                <option value="{$key}">{$val}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">下单时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="create_time" id="create_time" placeholder="请选择下单时间" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="batchdel">删除</button>
                {if $role['role_id']==3}
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="edit">添加</button>
                {/if}
            </div>

            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
            <script type="text/html" id="imgTpl">
                {{# if(d.code){ }}
                <a href="/{{ d.code }}" target="_blank">
                <img style="display: inline-block; width: 50%; height: 100%;" src="/{{ d.code }}">
                </a>
                {{# } }}
            </script>

            <script type="text/html" id="payTpl">
                {{#  if(d.pay_status == 1){ }}
                <input type="checkbox" lay-filter="status_change" field="{{d.status_field}}" table_name="{{d.status_table}}"
                       id="{{d.id}}" checked lay-skin="switch" lay-text="已付款|未付款">
                {{#  } else { }}
                <input type="checkbox" lay-filter="status_change" field="{{d.status_field}}" table_name="{{d.status_table}}"
                       id="{{d.id}}" lay-skin="switch" lay-text="已付款|未付款">
                {{#  } }}
            </script>

            <script type="text/html" id="table-useradmin-webuser">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
                        class="layui-icon layui-icon-edit"></i>编辑</a>
                <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i-->
                        <!--class="layui-icon layui-icon-delete"></i>删除</a>-->
            </script>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , laydate = layui.laydate;

        laydate.render({
            elem: '#create_time' //指定元素
            ,range: true
        });

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-user-manage', {
                where: field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //用户管理
        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url('order/ajaxIndex')}" //模拟接口
            , cols: [[
                  {type: 'checkbox', fixed: 'left'}
                , {field: 'id', width: 50, title: 'ID', sort: true}
                , {field: 'order_sn', title: '订单编号',width:180}
                , {field: 'shop_name', title: '来源'}
                , {field: 'start_city', title: '出发城市'}
                , {field: 'end_city', title: '终点城市'}
                , {field: 'site', title: '出发站点', minWidth: 100}
                , {field: 'number', title: '人数', minWidth: 100}
                , {field: 'realname', title: '联系人', minWidth: 100}
                , {field: 'mobile', title: '联系电话', minWidth: 100}
                , {field: 'code', title: '二维码', minWidth: 100,toolbar:'#imgTpl'}
                , {field: 'status', title: '状态', minWidth: 80, align: 'center'}
                , {field: 'create_time', title: '下单时间', sort: true}
                , {title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
            ]]
            , method: 'post'
            , page: true
            , limit: 30
            , height: 'full-180'
            , text: '对不起，加载出现异常！'
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            var url = "";
            if (type == 'add') {
                url = "{:url('order/add')}";
            }
            active[type] ? active[type].call(this, url, table) : '';
        });
    });
</script>
</body>
</html>
{/block}
